package com.xiangyu.userservice.controller;

import com.commonapi.commonapi.OrderServiceFeignClient;
import com.commonmodule.commonmodule.module.Order;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

/**
 * @author zxb
 * @version 1.0
 * @date 2025-04-02 16:45
 */
@Slf4j
@RestController
@RequestMapping("/user")
@RefreshScope  // 读取配置文件的注解
public class UserController {

    @Resource
    private OrderServiceFeignClient orderServiceFeignClient;

    // 从nacos配置中心获取配置信息
    @Value("${config.info}")
    private String configInfo;

    @GetMapping
    public void getUser(){
        log.info("用户服务");
        System.out.println("获取用户列表！！！");
    }

    @GetMapping("/configInfo")
    public void configInfo(){
        System.out.println(configInfo);
    }


    @PostMapping("/userOrder")
    public void orderUser(@RequestBody Order order) {
        System.out.println("远程调用userService服务成功");
        System.out.println(order);
    }


    @PostMapping
    public void getOrder(){
        Order order = new Order();
        order.setOrderId("123456");
        order.setPrice(28.5);
        orderServiceFeignClient.orderUser(order);
    }


}
